package cn.hbads.support.structure.trait;

import java.util.Objects;

/**
 * <b> 主键区分特征接口 </b>
 *
 * @author : yvvb
 * @since : 2025/5/23
 */
public abstract class KeyTrait<T> {

    protected abstract T key();

    @Override
    public int hashCode() {
        return Objects.hash(key());
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof KeyTrait other)) {
            return false;
        }
        return Objects.equals(this.key(), other.key());
    }

}
